using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using ComputerShopE3.Models;

namespace ComputerShopE3.Controllers
{
    public class PaymentController : Controller
    {
        ComputerShopDBEntities1 _db = new ComputerShopDBEntities1();
        //
        // GET: /Payment/

        public ActionResult Index()
        {
            return View(_db.PT_THANH_TOAN.ToList());
        }

        //
        // GET: /Payment/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Payment/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Payment/Create

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude="id")]PT_THANH_TOAN ptttToCreate)
        {
            try
            {
                // TODO: Add insert logic here
                _db.AddToPT_THANH_TOAN(ptttToCreate);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Payment/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View(_db.PT_THANH_TOAN.Where(pt => pt.id == id).First());
        }

        //
        // POST: /Payment/Edit/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(PT_THANH_TOAN ptttToEdit)
        {
            try
            {
                PT_THANH_TOAN originalPTTT = _db.PT_THANH_TOAN.Where(pt => pt.id == ptttToEdit.id).First();
                _db.ApplyPropertyChanges(originalPTTT.EntityKey.EntitySetName, ptttToEdit);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
